package com.zzyl.nursing.controller.member;

import com.aliyun.iot20180120.models.QueryDevicePropertyStatusRequest;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.nursing.controller.PropertyStatusInfo;
import com.zzyl.nursing.domain.Device;
import com.zzyl.nursing.dto.DeviceDataListDto;
import com.zzyl.nursing.dto.FamilyMemberDto;
import com.zzyl.nursing.dto.UserLoginRequestDto;
import com.zzyl.nursing.service.IDeviceDataService;
import com.zzyl.nursing.service.IFamilyMemberService;
import com.zzyl.nursing.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 老人家属Controller
 * 
 * @author ruoyi
 * @date 2024-09-19
 */
@RestController
@RequestMapping("/member/user")
@Api(tags = "老人家属的接口")
public class FamilyMemberController extends BaseController
{
    @Autowired
    private IFamilyMemberService familyMemberService;


    @PostMapping("/login")
    @ApiOperation("小程序登录")
    public AjaxResult login(@RequestBody UserLoginRequestDto dto){
        LoginVo loginVo = familyMemberService.login(dto);
        return success(loginVo);
    }

    //绑定老人
    @PostMapping("/add")
    @ApiOperation("绑定老人")
    public AjaxResult bindElder(@RequestBody FamilyMemberDto familyMemberDto){
        familyMemberService.bindElder(familyMemberDto);
        return success(familyMemberDto);
    }

    //查询老人列表
    @GetMapping("/my")
    public AjaxResult getFamilyMemberList() {
        List<FamilyMemberVo> familyMemberVos = familyMemberService.getFamilyMemberList();
        return success(familyMemberVos);
    }

    @ApiOperation("查看家人列表(分页查询)")
    @GetMapping("/list-by-page")
    public AjaxResult listByPage(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                 @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize){
        List<FamilyElderVo>  list = familyMemberService.selectPage(pageNum,pageSize);
        return success(list);
    }


    /**
     * 查询健康数据
     */
    @ApiOperation("查询健康数据")
    @PostMapping("/QueryDevicePropertyStatus")
    public AjaxResult queryDevicePropertyStatus(@RequestBody QueryDevicePropertyStatusRequest request){
        return familyMemberService.queryDevicePropertyStatus(request);
    }

    @Autowired
    private IDeviceDataService deviceDataService;

    /**
     * 按天统计查询指标数据
     */
    @ApiOperation("按天统计查询指标数据")
    @GetMapping("/queryDeviceDataListByDay")
    public AjaxResult queryDeviceDataListByDay(DeviceDataListDto deviceDataListDto){
        List<DeviceDataListVo> list = deviceDataService.queryDeviceDataListByDay(deviceDataListDto);
        return AjaxResult.success(list);
    }

}
